/*
 * @Author: sunzhijun 
 * @Date: 2019-07-31 16:24:02 
 * @Last Modified by: sunzhijun
 * @Last Modified time: 2020-03-20 14:33:25
 */
export default class ButtonAction {
    constructor(comp) {
        this.comp = comp;
    }

    // 无组织按钮显示状态
    noneOrgButtonStatus = () => {
        const {props} = this.comp;
        const {button} = props;
        button.setButtonVisible({
            // Add: false,
            Edit: false,
            // Delete: false,
            // BatchEdit: false, //批改
            // Query: false, //查询
            // More: false, //更多
            // Termination: false, //终止关系
            // Die: false, //身故处理
            Save: false, //保存
            SaveAdd: false, //保存新增
            Cancel: false,
            // Refresh: false,
            First: false,
            Next: false,
            Pre: false,
            Last: false
        });
        button.setButtonDisabled({
            Add: true,
            Edit: true,
            Delete: true,
            BatchEdit: true, //批改
            Query: true, //查询
            More: true, //更多
            Termination: true, //终止关系
            Die: true, //身故处理
            Refresh: true
        });
    };

    // 有组织无数据按钮显示状态
    orgButtonNoDataStatus = ()=>{
        const {props} = this.comp;
        const {button} = props;
        button.setButtonDisabled({
            Add: false,
            // Edit: true,
            Delete: true,
            BatchEdit: true, //批改
            Query: false, //查询
            More: true, //更多
            Termination: true, //终止关系
            Die: true, //身故处理
            Refresh: true
        });
        button.setButtonVisible({
            Save: false, //保存
            Cancel: false,
            Add: true,
            SaveAdd: false, //保存新增
            Edit: false,
            Delete: true,
            BatchEdit: true, //批改
            Query: true, //查询
            More: true, //更多
            Termination: true, //终止关系
            Die: true, //身故处理
            Refresh: true
        });
    }

    //已浏览态进入卡片页只显示修改按钮
    onlyEditButtonStatus = ()=>{
        const {props} = this.comp;
        const {button} = props;
        button.setButtonVisible({
            Save: false, //保存
            Cancel: false,
            Add: false,
            SaveAdd: false, //保存新增
            Edit: true,
            Delete: false,
            BatchEdit: false, //批改
            Query: false, //查询
            More: false, //更多
            Termination: false, //终止关系
            Die: false, //身故处理
            Refresh: false
        });
    }

    // 有组织有数据按钮显示状态
    orgButtonDataStatus = ()=>{
        const {props} = this.comp;
        const {button} = props;
        button.setButtonDisabled({
            Add: false,
            Edit: false,
            Delete: false,
            BatchEdit: false, //批改
            Query: false, //查询
            More: false, //更多
            Termination: false, //终止关系
            Die: false, //身故处理
            Refresh: false
        });
        button.setButtonVisible({
            Save: false, //保存
            Cancel: false,
            Add: true,
            SaveAdd: false, //保存新增
            Edit: false,
            Delete: true,
            BatchEdit: true, //批改
            Query: true, //查询
            More: true, //更多
            Termination: true, //终止关系
            Die: true, //身故处理
            Refresh: true
        });
    }

    // 新增时按钮状态
    newButtonStatus = ()=>{
        const {props} = this.comp;
        const {button} = props;
        button.setButtonVisible({
            Save: true, //保存
            Cancel: true,
            Add: false,
            SaveAdd: true, //保存新增
            Edit: false,
            Delete: false,
            BatchEdit: false, //批改
            Query: false, //查询
            More: false, //更多
            Termination: false, //终止关系
            Die: false, //身故处理
            Refresh: false
        });
    }

    // 编辑态取消时按钮状态
    cancelButtonStatus = ()=>{
        const {props} = this.comp;
        const {button} = props;
        button.setButtonVisible({
            Save: false, //保存
            Cancel: false,
            SaveAdd: false, //保存新增
            Edit: true,
        });
        button.setButtonDisabled({
            Edit: false
        })
    }

    //设置排序按钮状态
    sortButtonStatus = ()=>{
        const {props} = this.comp;
        const {button} = props;
        button.setButtonVisible({
            Save: true, //保存
            Cancel: true,
            Add: false,
            BatchEdit: false, //批改
            Query: false, //查询
            More: false, //更多
            Termination: false, //终止关系
            Die: false, //身故处理
            Refresh: false
        });
    }
    //取消排序时按钮状态
    cancelSortButtonStatus = ()=>{
        const {props} = this.comp;
        const {button} = props;
        button.setButtonVisible({
            Save: false, //保存
            Cancel: false,
            Add: true,
            BatchEdit: true, //批改
            Query: true, //查询
            More: true, //更多
            Termination: true, //终止关系
            Die: true, //身故处理
            Refresh: true
        });
    }

    //单双击时进入cradForm页面按钮状态
    toFormPageButtonStatus = () =>{
        const {props} = this.comp;
        const {button, main} = props;
        button.setButtonVisible({
            Add: true,
            Edit: true,
            Delete: true,
            PublishAction: true,
            TempPrint: false,
            Save: false,
            Cancel: false,
            SaveAdd: false,
            refresh: false
        });
    };

    //设置是否禁用批量增加子集
    setBatchEditButtonStatus = ( isDisabled )=>{
        const { props } = this.comp;
        const { button } = props;
        button.setButtonDisabled({
            BatchAddSub: !isDisabled
        })
    }
    
    // 按钮点击回调-主按钮区
    handleButton = (props, btnCode) => {
        const {action} = this.comp;
        switch (btnCode) {
            case 'Add': 
                action.headerAct.add();
                break;
            case 'Edit':
                action.tableAct.editPersonnelInfo();
                break;
            case 'Save':
                action.cardAct.saveDataAction();
                break;
            case 'SaveAdd': 
                action.cardAct.saveDataAction('newAdd');
                break;
            case 'Cancel':
                action.cardAct.cancel();
                break;
            case 'Delete':
                action.tableAct.deletePersonnelInfo();
                break;
            case 'Refresh':
                action.tableAct.refresh();
                break;
            case 'BatchEdit': 
                action.headerAct.batchEdit();
                break;
            case 'Termination': 
                action.headerAct.termination();
                break;
            case 'Query':
                action.headerAct.query();
                break;
            case 'Die':
                action.headerAct.dieCheckAction();
                break;
            case 'Sort':
                action.headerAct.sortModalVisible();
                break;
            case 'ExportPhoto':
                action.headerAct.exportPhoto();
                break;
            case 'File': 
                action.headerAct.fileManager();
                break;
            case 'AdjustSort':
                action.headerAct.adjustSort();
                break;
            case 'BatchAddSub':
                action.headerAct.batchAddSub();
                break;
            case 'Print':
                action.headerAct.printAction();
                break;
            case 'Output':
                action.headerAct.outputAction();
                break;
            case 'cardview':
                action.headerAct.showCardview();
                break;
            default:
                break;
        }
    }
}